package club.xyes.zkh.ecommerce.commons.vo;

import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.util.List;

/**
 * Create by 郭文梁 2019/5/7 0007 20:06
 * LayUiDataGrid
 * LayUIDataGrid数据格式
 *
 * @author 郭文梁
 * @data 2019/5/7 0007
 */
@Data
public class LayUiDataGrid<T> {
    /**
     * 从PageInfo创建
     *
     * @param pageInfo PageInfo对象
     * @param <T>      数据类型
     * @return LayUiDataGrid
     */
    public static <T> LayUiDataGrid<T> fromPageInfo(PageInfo<T> pageInfo) {
        LayUiDataGrid<T> res = new LayUiDataGrid<>();
        res.code = 0;
        res.msg = "";
        res.count = pageInfo.getTotal();
        res.data = pageInfo.getList();
        return res;
    }

    private Integer code;
    private String msg;
    private Long count;
    private List<T> data;
}
